package com.zaki.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zaki.mapper.UserMapper;
import com.zaki.model.User;
import com.zaki.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public PageInfo<User> selectList(Integer pageSize, Integer pageNum) {
        PageHelper.startPage(pageSize,pageNum);
        List<User> userList =userMapper.selectList();
        return new PageInfo<User>(userList);
    }

    @Transactional(rollbackFor = Exception.class) //这个就是指定所有的异常都会回滚
    @Override
    public User selectByUserNameAndPassword(String username, String password) {
        return userMapper.selectByUserNameAndPassword(username,password);
    }


}
